package word418;

import java.util.*;


import word418.compclass.*;

public class TestComparator {
  public static void main(String[] args) {
    school g1 = new student("魏十一",58,1.65);
    school g2 = new teacher("川哥",60,1.75);
    school g3= new chore("老汤",55,1.60);

    school g =
            max(g1, g2, new SchoolObjectComparator());

    System.out.println("这里bim指数最大的那个是： " +
            g.getBmi());

    List<school> geometricObjectList=new ArrayList<school>();
    geometricObjectList.add(g1);
    geometricObjectList.add(g2);
    geometricObjectList.add(g3);


    Collections.sort(geometricObjectList,new SchoolObjectComparator());
    Collections.reverse(geometricObjectList);
    Collections.max(geometricObjectList,new SchoolObjectComparator());

    for (school item:geometricObjectList
         ) {
      System.out.println(item.getBmi());
    }
  }
  
  public static school max(school g1,
                           school g2, Comparator<school> c) {
    if (c.compare(g1, g2) > 0)
      return g1;
    else
      return g2;
  }
}